<?php

//许愿墙控制器
class WishControl extends CommonControl{
	//默认显示方法
	public function index(){
		$db = M('wish');
		$page = new page($db->count(), 10, 4, 2);
		$this->assign('page',$page->show());
		$wish = $db->select($page->limit());
		foreach ($wish as $k => $v) {
			# code...
			$wish[$k]['content'] = $this->change_face($v['content']);
		}
		$this->assign('wish',$wish);
		$this->display();
	}


	//删除
	public function del(){
		$wid = $this->_GET('wid','intval');
		M('wish')->where(array('wid'=>$wid))->delete();
		$this->success('删除成功！！！');
	}







	//替换表情
	public function change_face($content){
		$preg = '/\[(\w*?)\]/';
		$con = preg_replace($preg, '<img src="' . __PUBLIC__ .'/images/phiz/\1.gif"/>', $content);
		return $con;
	}



}
?>